package com.tfswue.springboot_demo02.listener;

import com.tfswue.springboot_demo02.event.UserRegisteredEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class UserEventListener implements ApplicationListener<UserRegisteredEvent> {
    private static final Logger logger = LoggerFactory.getLogger(UserEventListener.class);

    @Override
    public void onApplicationEvent(UserRegisteredEvent event) {
        logger.info("记录用户注册日志: {} | {}", event.getUsername(), event.getEmail());
        // 这里可以添加日志记录逻辑
    }
}